package com.monkeys.controller;

import com.monkeys.pojo.Result;
import com.monkeys.service.WhileService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author KuangTeam
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/while")
public class WhileController {

    private final WhileService whileService;

    //开始循环之前生成车辆和订单，前端传递开始货车的数量和订单的数量
    @GetMapping("/generatedData/{vehicleNum}/{goodsDemandNum}")
    public Result<Object> generatedData(@PathVariable Long vehicleNum, @PathVariable Long goodsDemandNum) {
        whileService.generatedData(vehicleNum, goodsDemandNum);
        return Result.success();
    }


    //开始循环,前端传递一次循环的时间(秒)还有每秒代表模拟的时间(小时)     比如传递1/0.1 代表一次循环1s，1s代表模拟的10min
    @GetMapping("start/{second}/{hour}")
    public Result<Object> startSimulation(@PathVariable Long second, @PathVariable Double hour) {
        whileService.startSimulation(second, hour);
        return Result.success();
    }

}
